using System.Web.UI;
using System.Web.UI.HtmlControls;

namespace FluentTags
{

    public class ImgTag : Tag<ImgTag>
    {
        public ImgTag() : base("img"){}
        
        
        public ImgTag(Control control) : this()
        {
            Controls.Add(control);
        }
        
        
        public ImgTag Alt(string value)
        {   
            Attributes.Add("alt", value.ToString());
            return this;
        }
        
        public ImgTag Height(string value)
        {   
            Attributes.Add("height", value.ToString());
            return this;
        }
        
        public ImgTag Ismap(string value)
        {   
            Attributes.Add("ismap", value.ToString());
            return this;
        }
        
        public ImgTag Longdesc(string value)
        {   
            if(!value.StartsWith("#"))
            {
                value = ResolveUrl(value);
            }
                    
            Attributes.Add("longdesc", value.ToString());
            return this;
        }
        
        public ImgTag Src(string value)
        {   
            if(!value.StartsWith("#"))
            {
                value = ResolveUrl(value);
            }
                    
            Attributes.Add("src", value.ToString());
            return this;
        }
        
        public ImgTag Usemap(string value)
        {   
            if(!value.StartsWith("#"))
            {
                value = ResolveUrl(value);
            }
                    
            Attributes.Add("usemap", value.ToString());
            return this;
        }
        
        public ImgTag Width(string value)
        {   
            Attributes.Add("width", value.ToString());
            return this;
        }
        
        
        public string AltAttribute
        {
            get
            {
                return Attributes["alt"];
            }
        }
        
        public string HeightAttribute
        {
            get
            {
                return Attributes["height"];
            }
        }
        
        public string IsmapAttribute
        {
            get
            {
                return Attributes["ismap"];
            }
        }
        
        public string LongdescAttribute
        {
            get
            {
                return Attributes["longdesc"];
            }
        }
        
        public string SrcAttribute
        {
            get
            {
                return Attributes["src"];
            }
        }
        
        public string UsemapAttribute
        {
            get
            {
                return Attributes["usemap"];
            }
        }
        
        public string WidthAttribute
        {
            get
            {
                return Attributes["width"];
            }
        }
        
        
        
    }

    public class ImgTag<ParentType> : ChildTag<ImgTag<ParentType>, ParentType>
        where ParentType : HtmlGenericControl
    {
        public ImgTag(ParentType parent) : base("img", parent) { }

        
        public ImgTag<ParentType> Alt(string value)
        {   
            Attributes.Add("alt", value.ToString());
            return this;
        }
        
        public ImgTag<ParentType> Height(string value)
        {   
            Attributes.Add("height", value.ToString());
            return this;
        }
        
        public ImgTag<ParentType> Ismap(string value)
        {   
            Attributes.Add("ismap", value.ToString());
            return this;
        }
        
        public ImgTag<ParentType> Longdesc(string value)
        {   
            if(!value.StartsWith("#"))
            {
                value = ResolveUrl(value);
            }
                    
            Attributes.Add("longdesc", value.ToString());
            return this;
        }
        
        public ImgTag<ParentType> Src(string value)
        {   
            if(!value.StartsWith("#"))
            {
                value = ResolveUrl(value);
            }
                    
            Attributes.Add("src", value.ToString());
            return this;
        }
        
        public ImgTag<ParentType> Usemap(string value)
        {   
            if(!value.StartsWith("#"))
            {
                value = ResolveUrl(value);
            }
                    
            Attributes.Add("usemap", value.ToString());
            return this;
        }
        
        public ImgTag<ParentType> Width(string value)
        {   
            Attributes.Add("width", value.ToString());
            return this;
        }
        
        
        public string AltAttribute
        {
            get
            {
                return Attributes["alt"];
            }
        }
        
        public string HeightAttribute
        {
            get
            {
                return Attributes["height"];
            }
        }
        
        public string IsmapAttribute
        {
            get
            {
                return Attributes["ismap"];
            }
        }
        
        public string LongdescAttribute
        {
            get
            {
                return Attributes["longdesc"];
            }
        }
        
        public string SrcAttribute
        {
            get
            {
                return Attributes["src"];
            }
        }
        
        public string UsemapAttribute
        {
            get
            {
                return Attributes["usemap"];
            }
        }
        
        public string WidthAttribute
        {
            get
            {
                return Attributes["width"];
            }
        }
        
        
        
        
    }
}